class Solution:
    def checkInclusion(self, s1: str, s2: str) -> bool:
        if len(s2) < len(s1):
            return False

        # 计算s1的字符状态
        stat1 = [0] * 26
        for ch in s1:
            stat1[ord(ch) - 97] += 1

        # 初始化滑动窗口
        stat2 = [0] * 26
        for i in range(len(s1)):
            stat2[ord(s2[i]) - 97] += 1

        if stat1 == stat2:
            return True

        # 移动滑动窗口
        for i in range(len(s1), len(s2)):
            stat2[ord(s2[i]) - 97] += 1
            stat2[ord(s2[i - len(s1)]) - 97] -= 1
            if stat1 == stat2:
                return True

        return False


if __name__ == "__main__":
    print(Solution().checkInclusion(s1="ab", s2="eidbaooo"))  # True
    print(Solution().checkInclusion(s1="ab", s2="eidboaoo"))  # False
